<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>聊天 - 招聘APP</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            background-color: #f9f9f9;
            height: 100vh;
        }
        .app-container {
            max-width: 390px;
            height: 100%;
            margin: 0 auto;
            background-color: white;
            display: flex;
            flex-direction: column;
        }
        .chat-header {
            padding: 10px 15px;
            border-bottom: 1px solid #eee;
            display: flex;
            align-items: center;
            justify-content: space-between;
            background-color: white;
            position: sticky;
            top: 0;
            z-index: 10;
        }
        .chat-header-left {
            display: flex;
            align-items: center;
        }
        .chat-header-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            object-fit: cover;
            margin-right: 10px;
        }
        .chat-header-info {
            display: flex;
            flex-direction: column;
        }
        .chat-header-name {
            font-weight: 600;
            font-size: 16px;
        }
        .chat-header-status {
            font-size: 12px;
            color: #52c41a;
        }
        .chat-header-actions {
            display: flex;
            gap: 15px;
        }
        .chat-header-action {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: #f5f5f5;
            color: #666;
            cursor: pointer;
            transition: all 0.3s;
        }
        .chat-header-action:hover {
            background-color: #e0e0e0;
        }
        .chat-header-action.video {
            background-color: #1677ff;
            color: white;
        }
        .chat-body {
            flex: 1;
            padding: 15px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 15px;
            background-color: #f5f5f7;
        }
        .message {
            display: flex;
            gap: 10px;
            max-width: 80%;
        }
        .message.sent {
            align-self: flex-end;
            flex-direction: row-reverse;
        }
        .message-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            object-fit: cover;
        }
        .message-content {
            padding: 10px 15px;
            border-radius: 18px;
            font-size: 14px;
            position: relative;
        }
        .message.received .message-content {
            background-color: white;
            border-top-left-radius: 4px;
        }
        .message.sent .message-content {
            background-color: #1677ff;
            color: white;
            border-top-right-radius: 4px;
        }
        .message-time {
            font-size: 12px;
            color: #999;
            margin-top: 5px;
            text-align: center;
        }
        .message-status {
            font-size: 12px;
            color: #999;
            margin-top: 2px;
            text-align: right;
        }
        .message-status i {
            margin-left: 2px;
        }
        .message.read .message-status {
            color: #1677ff;
        }
        .chat-footer {
            padding: 10px 15px;
            border-top: 1px solid #eee;
            background-color: white;
            position: sticky;
            bottom: 0;
        }
        .chat-input-container {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .chat-input {
            flex: 1;
            padding: 10px 15px;
            border-radius: 20px;
            border: 1px solid #e0e0e0;
            background-color: #f5f5f5;
            font-size: 14px;
            outline: none;
        }
        .chat-input:focus {
            border-color: #1677ff;
            background-color: white;
        }
        .chat-send {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: #1677ff;
            color: white;
            cursor: pointer;
            transition: all 0.3s;
        }
        .chat-send:hover {
            background-color: #0e5ecc;
        }
        .chat-actions {
            display: flex;
            gap: 15px;
            margin-right: 10px;
        }
        .chat-action {
            color: #666;
            font-size: 20px;
            cursor: pointer;
        }
        .date-divider {
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 20px 0;
            color: #999;
            font-size: 12px;
        }
        .date-divider::before,
        .date-divider::after {
            content: '';
            flex: 1;
            height: 1px;
            background-color: #eee;
        }
        .date-divider::before {
            margin-right: 15px;
        }
        .date-divider::after {
            margin-left: 15px;
        }
        .system-message {
            text-align: center;
            padding: 10px;
            background-color: rgba(22, 119, 255, 0.1);
            border-radius: 10px;
            color: #1677ff;
            font-size: 12px;
            margin: 10px 0;
        }
        .video-call-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.8);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 100;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.3s, visibility 0.3s;
        }
        .video-call-overlay.active {
            opacity: 1;
            visibility: visible;
        }
        .video-container {
            width: 100%;
            max-width: 390px;
            height: 100%;
            max-height: 844px;
            position: relative;
            background-color: black;
            overflow: hidden;
        }
        .video-main {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .video-self {
            position: absolute;
            top: 20px;
            right: 20px;
            width: 100px;
            height: 150px;
            border-radius: 10px;
            overflow: hidden;
            border: 2px solid white;
        }
        .video-controls {
            position: absolute;
            bottom: 40px;
            left: 0;
            right: 0;
            display: flex;
            justify-content: center;
            gap: 20px;
        }
        .video-control {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: rgba(255, 255, 255, 0.2);
            color: white;
            cursor: pointer;
            transition: all 0.3s;
        }
        .video-control:hover {
            background-color: rgba(255, 255, 255, 0.3);
        }
        .video-control.end-call {
            background-color: #ff4d4f;
        }
        .video-control.end-call:hover {
            background-color: #ff7875;
        }
        .video-info {
            position: absolute;
            top: 20px;
            left: 20px;
            color: white;
        }
        .video-name {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 5px;
        }
        .video-timer {
            font-size: 14px;
        }
    </style>
</head>
<body>
    <div class="app-container">
        <div class="chat-header">
            <div class="chat-header-left">
                <a href="chat-list.html" class="mr-2">
                    <i class="fas fa-arrow-left"></i>
                </a>
                <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTB8fHByb2ZpbGV8ZW58MHx8MHx8&auto=format&fit=crop&w=100&h=100&q=80" alt="张伟" class="chat-header-avatar">
                <div class="chat-header-info">
                    <span class="chat-header-name">张伟</span>
                    <span class="chat-header-status">在线</span>
                </div>
            </div>
            <div class="chat-header-actions">
                <div class="chat-header-action" id="schedule-interview">
                    <i class="fas fa-calendar-alt"></i>
                </div>
                <div class="chat-header-action video" id="start-video-call">
                    <i class="fas fa-video"></i>
                </div>
                <div class="chat-header-action" id="send-contract">
                    <i class="fas fa-id-card"></i>
                </div>
                <div class="chat-header-action">
                    <i class="fas fa-ellipsis-v"></i>
                </div>
            </div>
        </div>
        
        <div class="chat-body" id="chat-body">
            <div class="date-divider">
                <span>今天</span>
            </div>
            
            <div class="system-message" id="system-schedule" style="display:none;"></div>
            <div class="system-message" id="system-report" style="display:none;"></div>
            
            <div class="message received">
                <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTB8fHByb2ZpbGV8ZW58MHx8MHx8&auto=format&fit=crop&w=100&h=100&q=80" alt="张伟" class="message-avatar">
                <div>
                    <div class="message-content">
                        您好，我对贵公司的前端开发职位很感兴趣，想了解一下具体的工作内容和技术栈要求。
                    </div>
                    <div class="message-time">10:15</div>
                </div>
            </div>
            
            <div class="message sent read">
                <img src="https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8Y29tcGFueXxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=100&h=100&q=80" alt="科技智联" class="message-avatar">
                <div>
                    <div class="message-content">
                        您好，张伟！很高兴收到您的消息。我们正在寻找熟悉React和TypeScript的前端开发工程师，主要负责我们的SaaS产品开发。您有这方面的经验吗？
                    </div>
                    <div class="message-time">10:18</div>
                    <div class="message-status">
                        已读 <i class="fas fa-check-double"></i>
                    </div>
                </div>
            </div>
            
            <div class="message received">
                <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTB8fHByb2ZpbGV8ZW58MHx8MHx8&auto=format&fit=crop&w=100&h=100&q=80" alt="张伟" class="message-avatar">
                <div>
                    <div class="message-content">
                        是的，我有3年React开发经验，最近两年一直在使用TypeScript。我之前参与过一个企业级SaaS项目的开发，主要负责前端架构和组件库的搭建。
                    </div>
                    <div class="message-time">10:20</div>
                </div>
            </div>
            
            <div class="message received">
                <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTB8fHByb2ZpbGV8ZW58MHx8MHx8&auto=format&fit=crop&w=100&h=100&q=80" alt="张伟" class="message-avatar">
                <div>
                    <div class="message-content">
                        我对性能优化和微前端架构也有一些研究，不知道贵公司是否有这方面的需求？
                    </div>
                    <div class="message-time">10:21</div>
                </div>
            </div>
            
            <div class="message sent">
                <img src="https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8Y29tcGFueXxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=100&h=100&q=80" alt="科技智联" class="message-avatar">
                <div>
                    <div class="message-content">
                        太好了！您的经验非常符合我们的需求。我们正在构建一个微前端架构的大型应用，性能优化是我们非常关注的点。您能否分享一下您在这方面的具体经验？
                    </div>
                    <div class="message-time">10:25</div>
                    <div class="message-status">
                        已发送 <i class="fas fa-check"></i>
                    </div>
                </div>
            </div>
            
            <div class="message received">
                <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTB8fHByb2ZpbGV8ZW58MHx8MHx8&auto=format&fit=crop&w=100&h=100&q=80" alt="张伟" class="message-avatar">
                <div>
                    <div class="message-content">
                        在之前的项目中，我们使用了qiankun框架实现微前端架构，将一个大型应用拆分成多个子应用，实现了独立开发、独立部署。在性能优化方面，我主要采用了代码分割、懒加载、虚拟列表等技术，使首屏加载时间从3.5s优化到了1.2s。
                    </div>
                    <div class="message-time">10:30</div>
                </div>
            </div>
            
            <div class="message sent">
                <img src="https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8Y29tcGFueXxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=100&h=100&q=80" alt="科技智联" class="message-avatar">
                <div>
                    <div class="message-content">
                        这非常棒！我们也在使用类似的技术栈。您方便进行一次视频面试吗？我们可以更深入地交流一下技术细节和您对我们项目的想法。
                    </div>
                    <div class="message-time">10:32</div>
                    <div class="message-status">
                        发送中...
                    </div>
                </div>
            </div>
        </div>
        
        <div class="chat-footer">
            <div class="chat-input-container">
                <div class="chat-actions">
                    <div class="chat-action">
                        <i class="far fa-image"></i>
                    </div>
                    <div class="chat-action">
                        <i class="far fa-file"></i>
                    </div>
                </div>
                <input type="text" class="chat-input" placeholder="输入消息...">
                <div class="chat-send">
                    <i class="fas fa-paper-plane"></i>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 日程弹窗 -->
    <div class="video-call-overlay" id="schedule-overlay">
        <div class="video-container" style="max-height: 420px; background:#fff; border-radius:12px; overflow:hidden;">
            <div class="p-4">
                <div class="text-lg font-semibold mb-2">安排视频面试</div>
                <div class="text-sm text-gray-500 mb-4">请选择时间与方式</div>
                <div class="space-y-3">
                    <div>
                        <label class="text-sm text-gray-600">日期</label>
                        <input type="date" id="schedule-date" class="w-full mt-1 p-2 border rounded" />
                    </div>
                    <div class="grid grid-cols-2 gap-2">
                        <div>
                            <label class="text-sm text-gray-600">开始时间</label>
                            <input type="time" id="schedule-start" class="w-full mt-1 p-2 border rounded" />
                        </div>
                        <div>
                            <label class="text-sm text-gray-600">时长(分钟)</label>
                            <input type="number" id="schedule-duration" min="15" step="15" value="30" class="w-full mt-1 p-2 border rounded" />
                        </div>
                    </div>
                    <div>
                        <label class="text-sm text-gray-600">面试形式</label>
                        <select id="schedule-type" class="w-full mt-1 p-2 border rounded">
                            <option value="video">视频面试</option>
                            <option value="phone">电话面试</option>
                            <option value="onsite">现场面试</option>
                        </select>
                    </div>
                </div>
                <div class="flex justify-end gap-2 mt-4">
                    <button id="schedule-cancel" class="px-4 py-2 bg-gray-100 rounded">取消</button>
                    <button id="schedule-confirm" class="px-4 py-2 bg-blue-600 text-white rounded">确定</button>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 视频通话弹窗(保留) -->
    <div class="video-call-overlay" id="video-call-overlay">
        <div class="video-container">
            <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTB8fHByb2ZpbGV8ZW58MHx8MHx8&auto=format&fit=crop&w=500&h=800&q=80" alt="视频通话" class="video-main">
            <div class="video-self">
                <img src="https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8Y29tcGFueXxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=200&h=300&q=80" alt="自己" style="width: 100%; height: 100%; object-fit: cover;">
            </div>
            <div class="video-info">
                <div class="video-name">张伟</div>
                <div class="video-timer">00:05:32</div>
            </div>
            <div class="video-controls">
                <div class="video-control">
                    <i class="fas fa-microphone-slash"></i>
                </div>
                <div class="video-control">
                    <i class="fas fa-video-slash"></i>
                </div>
                <div class="video-control end-call" id="end-call-btn">
                    <i class="fas fa-phone-slash"></i>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 调度与视频通话功能
        const scheduleBtn = document.getElementById('schedule-interview');
        const scheduleOverlay = document.getElementById('schedule-overlay');
        const scheduleCancel = document.getElementById('schedule-cancel');
        const scheduleConfirm = document.getElementById('schedule-confirm');
        const systemSchedule = document.getElementById('system-schedule');
        const systemReport = document.getElementById('system-report');
        const startVideoCallBtn = document.getElementById('start-video-call');

        // 初始化：显示最近一次面试报告/日程
        (function(){
            const lastSchedule = JSON.parse(localStorage.getItem('lastInterviewSchedule') || 'null');
            if (lastSchedule) {
                systemSchedule.style.display = 'block';
                systemSchedule.textContent = `面试已安排：${lastSchedule.date} ${lastSchedule.start}，时长${lastSchedule.duration}分钟（${lastSchedule.type === 'video' ? '视频面试' : lastSchedule.type}）`;
            }
            const lastReport = JSON.parse(localStorage.getItem('lastInterviewReport') || 'null');
            if (lastReport) {
                systemReport.style.display = 'block';
                systemReport.innerHTML = `已生成面试报告：评分${lastReport.score || '—'}，<a href="#" id="view-report" class="text-blue-600">点击查看</a>`;
            }
        })();

        scheduleBtn.addEventListener('click', () => {
            scheduleOverlay.classList.add('active');
        });
        scheduleCancel.addEventListener('click', () => {
            scheduleOverlay.classList.remove('active');
        });
        scheduleConfirm.addEventListener('click', () => {
            const date = document.getElementById('schedule-date').value;
            const start = document.getElementById('schedule-start').value;
            const duration = parseInt(document.getElementById('schedule-duration').value, 10) || 30;
            const type = document.getElementById('schedule-type').value;
            if (!date || !start) return alert('请先选择日期和开始时间');
            const schedule = { date, start, duration, type, createdAt: Date.now() };
            localStorage.setItem('lastInterviewSchedule', JSON.stringify(schedule));
            systemSchedule.style.display = 'block';
            systemSchedule.textContent = `面试已安排：${date} ${start}，时长${duration}分钟（${type === 'video' ? '视频面试' : type}）`;
            scheduleOverlay.classList.remove('active');
        });

        // 视频通话按钮：必须先有日程才允许
        startVideoCallBtn.addEventListener('click', () => {
            const lastSchedule = JSON.parse(localStorage.getItem('lastInterviewSchedule') || 'null');
            if (!lastSchedule) {
                alert('请先安排面试日程');
                return;
            }
            document.getElementById('video-call-overlay').classList.add('active');
        });

        // 契约卡片发送
        const sendContractBtn = document.getElementById('send-contract');
        sendContractBtn.addEventListener('click', () => {
            const role = localStorage.getItem('role');
            if (role !== 'company') {
                return alert('仅企业端可发送契约卡片');
            }
            const chatBody = document.getElementById('chat-body');
            const contractHTML = `
                <div class="system-message">
                    契约卡片：前端开发工程师（科技智联）
                    <a href="onboarding.html" class="ml-2 text-blue-600">去入职流程</a>
                </div>
            `;
            chatBody.insertAdjacentHTML('beforeend', contractHTML);
            chatBody.scrollTop = chatBody.scrollHeight;
        });

        // 观看报告
        document.addEventListener('click', (e) => {
            if (e.target && e.target.id === 'view-report') {
                const report = JSON.parse(localStorage.getItem('lastInterviewReport') || 'null');
                if (!report) return;
                alert(`面试报告\n候选人：张伟\n评分：${report.score}\n要点：${report.highlights || '—'}`);
            }
        });

        // 发送消息功能
        const chatInput = document.querySelector('.chat-input');
        const sendBtn = document.querySelector('.chat-send');
        const chatBody = document.querySelector('.chat-body');
        
        function sendMessage() {
            const message = chatInput.value.trim();
            if (message) {
                const now = new Date();
                const hours = now.getHours().toString().padStart(2, '0');
                const minutes = now.getMinutes().toString().padStart(2, '0');
                const timeString = `${hours}:${minutes}`;
                
                const messageHTML = `
                    <div class="message sent">
                        <img src="https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8Y29tcGFueXxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=100&h=100&q=80" alt="科技智联" class="message-avatar">
                        <div>
                            <div class="message-content">
                                ${message}
                            </div>
                            <div class="message-time">${timeString}</div>
                            <div class="message-status">
                                发送中...
                            </div>
                        </div>
                    </div>
                `;
                
                chatBody.insertAdjacentHTML('beforeend', messageHTML);
                chatInput.value = '';
                
                // 滚动到底部
                chatBody.scrollTop = chatBody.scrollHeight;
                
                // 模拟消息发送状态变化
                setTimeout(() => {
                    const lastMessage = chatBody.lastElementChild;
                    const statusElement = lastMessage.querySelector('.message-status');
                    statusElement.innerHTML = '已发送 <i class="fas fa-check"></i>';
                    
                    // 模拟对方回复
                    setTimeout(() => {
                        const replyHTML = `
                            <div class="message received">
                                <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTB8fHByb2ZpbGV8ZW58MHx8MHx8&auto=format&fit=crop&w=100&h=100&q=80" alt="张伟" class="message-avatar">
                                <div>
                                    <div class="message-content">
                                        好的，我很期待与您进行视频面试！请问您方便在什么时间进行？
                                    </div>
                                    <div class="message-time">${hours}:${(parseInt(minutes) + 2).toString().padStart(2, '0')}</div>
                                </div>
                            </div>
                        `;
                        
                        chatBody.insertAdjacentHTML('beforeend', replyHTML);
                        chatBody.scrollTop = chatBody.scrollHeight;
                        
                        // 更新发送状态为已读
                        statusElement.innerHTML = '已读 <i class="fas fa-check-double"></i>';
                        lastMessage.classList.add('read');
                    }, 3000);
                }, 1000);
            }
        }
        
        sendBtn.addEventListener('click', sendMessage);
        
        chatInput.addEventListener('keypress', (e) => {
            if (e.key === 'Enter') {
                sendMessage();
            }
        });
    </script>
</body>
</html> 